<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>网站后台管理模版</title>
    <link rel="stylesheet" type="text/css" href="/public/static/admin/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/admin/css/admin.css" />
    <meta name="referrer" content="no-referrer" />
    <!-- 头部403 -->
    <!-- 图片上传 -->
    <script src="/public/static/admin/imgupdate/jquery.min.js"></script>
    <script src="/public/static/admin/imgupdate/jQuery.upload.min.js"></script>
    <link rel="stylesheet" href="/public/static/admin/imgupdate/upload.css">
    <!-- 图片上传 -->
    <script src="/public/static/admin/js/layer/layer.js"></script>
    <script src="/public/static/admin/xm-select/xm-select.js"></script>
    <style>
        body .layer-test {
            background: none;
            box-shadow: none;
        }
        /* 定制化 */
        
        html .layui-layer-demo {
            background-color: #eee;
        }
        
        .layui-layer-demo .layui-layer-title {
            border: none;
            background-color: #333;
            color: #fff;
        }
    </style>
    <script>
        var index = 1;
        var listTypeData = []; //渲染数据时候 这里记录了渲染的信息 只记录种类的 协作者 / 创作者
        var listIdOrUserNameData = []; //渲染数据时候 这里记录了渲染的信息 只记录用户名id
    </script>
</head>

<body>
    <div class="page-content-wrap">
        <div class="layui-tab" style="margin: 0;">
            <div class="layui-tab-content">
                <div class="layui-tab-item"></div>
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">漫画名称：</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" required lay-verify="required" value="{$bookInfo['title']}" placeholder="请输入漫画名称如： 我的妹妹不可能这么可爱/缘之空/···" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">简 介 ： </label>
                        <div class="layui-input-block">
                            <textarea type="tel" name="description" required lay-verify="required" placeholder="请输入漫画简介" autocomplete="off" class="layui-input">{$bookInfo['description']}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">添加作者<br>或协作者 </label>
                        <div class="layui-input-block">
                            <table id="add-author-chinese_team" class="layui-table">
                                <thead>
                                    <tr>
                                        <th style="width: 50px;">序号</th>
                                        <th>种类</th>
                                        <th>邮箱/id/用户名</th>
                                        <th>状态</th>
                                        <th style="width:10%;">信息</th>
                                        <th style="width:20%;">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <!-- 循环列表 -->
                                    {volist name='bookInfo["author_and_chinese_team"]' key="k" id='author_and_chinese_team_List'}
                                    <script>
                                        $button = '';
                                        $tr = ("{$author_and_chinese_team_List['user_id']}" == "{$user_info['_id']}") ?
                                            '<tr style="background-color:aqua;">' : '<tr>'; //判断是不是我自己是我自己就变成青色
                                        $authorOrChinese_team_select = ("{$bookInfo['me_role']}" == 'author') ? false : true; //判断是不是可以修改 创建者 /协作者
                                        var OriginalUserInformation = "{$author_and_chinese_team_List['hash_hmac_str']}"; //原始用户信息
                                        var me_token = "{$hashHmac_toKen}"; //我的验证信息
                                        var bookId = "{$bookId}"; //我的验证信息
                                        var time = "{$time}"; //时间戳
                                        var verificationBookId = "{$hashHmac_bookId}"; //我的验证信息

                                        $user_state = '未知状态'; //用户状态
                                        $user_info_msg = "undefined";
                                        var $edit_prohibit = false; //禁止编辑用户id
                                        switch ("{$author_and_chinese_team_List['state']}") {
                                            case "0":
                                                $user_state = "正常"
                                                    //判断是否允许继承用户
                                                if ("{$author_and_chinese_team_List['exp_state']}" == "10") { //判断用户状态是否被删除
                                                    $user_state = "正在被协作者申请踢出"
                                                    $user_info_msg = "被协作者删除 参考继承图 id-{$author_and_chinese_team_List['_id']}";
                                                    if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 作者直接允许踢出用户
                                                        $button +=
                                                            '<button type="button" onclick="RefuseToDeleteUser(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-danger refuse-to-delete-user">拒绝删除</button>';
                                                        $button +=
                                                            '<button type="button" onclick="AgreeToDeleteUser(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-warm agree-to-delete-user">同意删除用户</button>';
                                                    }
                                                } else {
                                                    if ("{$bookInfo['edit_delete_user']}" == "1") {
                                                        if ("{$author_and_chinese_team_List['user_id']}" ==
                                                            "{$user_info['_id']}") { //判断是不是我自己 并且允许显示编辑按钮
                                                            $edit_prohibit = false;
                                                            if ("{$author_and_chinese_team_List['edit_inherit_users']}" == 1) { //判断我是否拥有继承权限 
                                                                $button =
                                                                    '<button type="button" onclick="ModifyUserInformation(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-normal get">权限继承给ta</button>';
                                                            }
                                                        } else if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 作者直接允许修改用户
                                                            $edit_prohibit = false;
                                                            $button =
                                                                '<button type="button" onclick="ModifyUserInformation(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-normal get">修改用户信息</button>';
                                                        }
                                                    }

                                                    if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 作者直接允许踢出用户
                                                        $button +=
                                                            '<button type="button" onclick="Delete(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-danger del">移除项目</button>';
                                                    } else if ("{$author_and_chinese_team_List['user_id']}" == "{$user_info['_id']}") {
                                                        $button +=
                                                            '<button type="button" onclick="Delete(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-danger del">退出这个漫画</button>';
                                                    } else {
                                                        if ("{$bookInfo['edit_delete_user']}" == "1") { //是否允许删除用户 并且允许显示编辑按钮
                                                            $edit_prohibit = true;
                                                            $button +=
                                                                '<button type="button" onclick="Delete(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-danger del">申请踢出用户</button>';
                                                        }
                                                    }
                                                }
                                                break;
                                            case "1":
                                                $edit_prohibit = true;
                                                $user_state = "已停用";
                                                switch ("{$author_and_chinese_team_List['exp_state']}") {
                                                    case "0":
                                                        $user_info_msg = "协作者请求删除协作者";
                                                        break;
                                                    case "1":
                                                        $user_info_msg = "待审核";
                                                        break;
                                                    case "2":
                                                        if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 
                                                            $button +=
                                                                '<button type="button" onclick="RecoveryUser(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-warm recovery-user">恢复用户</button>';
                                                        }
                                                        $user_info_msg = "已被漫画创作者删除 参考id {$author_and_chinese_team_List['_id']}";
                                                        break;
                                                    case "3":
                                                        $user_info_msg = "转让自己的角色待审核";
                                                        break;
                                                    case "4":
                                                        $user_info_msg = "已转让";
                                                        break;
                                                    case "5":
                                                        $user_info_msg = "新加入待漫画作者审核";
                                                        break;
                                                    case "6":
                                                        $user_info_msg = "漫画作者审核未通过";
                                                        break;
                                                    case "7":
                                                        if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 
                                                            $button +=
                                                                '<button type="button" class="layui-btn layui-btn-warm invite_back">邀请回归</button>';
                                                        }
                                                        $user_info_msg = "自己退出项目";
                                                        break;
                                                    case "8":
                                                        $user_info_msg = "移交的项目";

                                                        break;
                                                    case "9":
                                                        $user_info_msg = "参考继承图";
                                                        if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 
                                                            $button +=
                                                                '<button type="button" onclick="InheritedUsersAreAllowedToJoin(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-normal inherited-users-are-allowed-to-join">允许继承加入</button>' +
                                                                '<button type="button" onclick="RefuseToInherit(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-warm refuse">拒绝加入</button>';
                                                        }
                                                        break;
                                                    case "10":
                                                        $user_info_msg = "被创作者删除";
                                                        break;
                                                    case "11":
                                                        $user_info_msg = "被协作者加入<p style='color:red'>待审核</p>";
                                                        if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 
                                                            $button +=
                                                                '<button type="button" onclick="AllowToJoin(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-radius layui-btn-warm allow-to-join">允许用户加入</button>' +
                                                                '<button type="button" onclick="RefuseToJoin(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-radius layui-btn-danger refuse-to-join">拒绝加入</button>';
                                                        }
                                                        break;
                                                    case "12":
                                                        $user_info_msg = "用户继承被管理员拒绝";
                                                        if ("{$bookInfo['me_role']}" == 'author') { //判断我是不是作者 
                                                            $button +=
                                                                '<button type="button" onclick="InviteToJoin(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-radius layui-btn-warm allow-to-join">邀请加入</button>';
                                                        }
                                                        break;
                                                    default:
                                                        $user_info_msg = "未知状态";
                                                        break;
                                                }
                                                if ("{$bookInfo['me_role']}" == 'author') {
                                                    $button +=
                                                        '<button type="button" onclick="DeleteStatusExceptionUser(\'{$author_and_chinese_team_List[\'user_id\']}\',\'{$author_and_chinese_team_List[\'hash_hmac_str\']}\')" class="layui-btn layui-btn-radius layui-btn-danger refuse-to-join">删除此用户信息</button>';
                                                }
                                                break;
                                            default:

                                                break;
                                        }


                                        var element = $([
                                            $tr,
                                            '<td>' + index + '</td>',
                                            '<td class="gender"></td>',
                                            '<td class="hobby"></td>',
                                            '<td class="state">' + $user_state + '</td>',
                                            '<td title="参考 分枝图 id-{$author_and_chinese_team_List[\'_id\']}" class="user_info_msg">' +
                                            $user_info_msg + '</td>',
                                            '<td class="handler">',
                                            $button,
                                            '',
                                            '</td>',
                                            '</tr>',
                                        ].join(''))
                                        listIdOrUserNameData["{$author_and_chinese_team_List['user_id']}"] = xmSelect.render({
                                            el: element.find('.hobby')[0],
                                            filterable: true,
                                            radio: true,
                                            remoteSearch: true,
                                            disabled: $edit_prohibit,
                                            model: {
                                                label: {
                                                    type: 'text'
                                                }
                                            },
                                            remoteMethod: function(val, cb, show) {
                                                //这里如果val为空, 则不触发搜索
                                                if (!val) {
                                                    return cb([]);
                                                }
                                                $.ajax({
                                                    type: "post",
                                                    url: 'SelectController/selectUserInfo',
                                                    data: {
                                                        keyword: val,
                                                        toKen: me_token, //用户token
                                                        bookId: bookId,
                                                        time: time,
                                                        verificationBookId: verificationBookId,
                                                    },
                                                    dataType: "json",
                                                    success: function(response) {
                                                        var res = response.data;
                                                        cb(res)
                                                    }
                                                });
                                            },
                                            data: [{
                                                name: '{$author_and_chinese_team_List["user_name"]}',
                                                value: "{$author_and_chinese_team_List['hash_hmac_str']}",
                                                selected: ("{$author_and_chinese_team_List['authorOrChinese_team']}" ==
                                                    '创建者') || ("{$author_and_chinese_team_List['authorOrChinese_team']}" ==
                                                    '协作者'),
                                            }]

                                        })

                                        var gender = element.find('.gender')[0];
                                        listTypeData["{$author_and_chinese_team_List['user_id']}"] = xmSelect.render({
                                            el: gender,
                                            radio: true,
                                            clickClose: true,
                                            disabled: $authorOrChinese_team_select,
                                            model: {
                                                label: {
                                                    type: 'text'
                                                }
                                            },
                                            data: function() {
                                                return [{
                                                    name: '创建者',
                                                    value: 0,
                                                    selected: ("{$author_and_chinese_team_List['authorOrChinese_team']}" ==
                                                        '创建者'),
                                                }, {
                                                    name: '协作者',
                                                    value: 1,
                                                    selected: ("{$author_and_chinese_team_List['authorOrChinese_team']}" ==
                                                        '协作者')
                                                }]
                                            },
                                            on: function(data) {
                                                if (!data.arr.length) {
                                                    alert('不可选择为空')
                                                }

                                            }.bind(listIdOrUserNameData["{$author_and_chinese_team_List['user_id']}"]),
                                        })


                                        element.find('.invite_back').on('click', function() { //恢复用户
                                            alert('待完善');
                                        })

                                        index++;

                                        $('#add-author-chinese_team tbody').append(element)
                                    </script>
                                    {/volist} {if condition="$bookInfo['edit_add_user'] eq 1"}
                                    <td colspan="6">
                                        <div style="height: 100%; width: 100%; margin-left: 22.0%;" class="layui-btn-group">
                                            <button style=" width: 50%;" type="button" class="layui-btn add">增加用户</button>
                                        </div>
                                    </td>
                                    <script>
                                        $('.add').on('click', function() {
                                            var element = $([
                                                '<tr>',
                                                '<td>' + index + '</td>',
                                                '<td class="gender"></td>',
                                                '<td class="hobby"></td>',
                                                '<td class="state">待提交</td>',
                                                '<td class="state">新增用户</td>',
                                                '<td class="handler">',
                                                '<button type="button" class="layui-btn layui-btn-normal enter-add-user">确认新增用户</button>',
                                                '<button type="button" class="layui-btn layui-btn-danger del">删除这行</button>',
                                                '</td>',
                                                '</tr>',
                                            ].join(''))

                                            var hobby = element.find('.hobby')[0];
                                            var hobbySelect = xmSelect.render({
                                                el: hobby,
                                                filterable: true,
                                                radio: true,
                                                remoteSearch: true,
                                                model: {
                                                    label: {
                                                        type: 'text'
                                                    }
                                                },
                                                remoteMethod: function(val, cb, show) {
                                                    if (val.length >= 7) {
                                                        $.ajax({
                                                            type: "post",
                                                            url: 'SelectController/selectUserInfo',
                                                            data: {
                                                                keyword: val,
                                                                toKen: me_token, //用户token
                                                                bookId: bookId,
                                                                time: time,
                                                                verificationBookId: verificationBookId,
                                                            },
                                                            dataType: "json",
                                                            success: function(response) {
                                                                var res = response.data;
                                                                cb(res)
                                                            }
                                                        });
                                                    } else {
                                                        cb([]);
                                                    }
                                                },
                                                data: []
                                            })

                                            var gender = element.find('.gender')[0];
                                            xmSelect.render({
                                                el: gender,
                                                radio: true,
                                                clickClose: true,
                                                disabled: true,
                                                model: {
                                                    label: {
                                                        type: 'text'
                                                    }
                                                },
                                                data: function() {
                                                    return [{
                                                        name: '协作者',
                                                        value: 2,
                                                        selected: true,

                                                    }]
                                                },
                                            })

                                            element.find('.enter-add-user').on('click', function() {
                                                $.ajax({
                                                    type: "post",
                                                    url: "AuthorAndChineseTeam/EnterAddUser",
                                                    data: {
                                                        "initListType": [0], //初始渲染时候的数据
                                                        "AddUser_id": [this.getValue('valueStr')], //要操作的用户信息
                                                        "toKen": me_token, //用户token
                                                        "bookId": bookId,
                                                        "time": time,
                                                        "verificationBookId": verificationBookId,
                                                    },
                                                    dataType: "json",
                                                    success: function(response) {

                                                    }
                                                });
                                            }.bind(hobbySelect))

                                            element.find('.del').on('click', function() {
                                                $(this).parents('tr').remove();
                                            })

                                            index++;

                                            $('#add-author-chinese_team tbody').append(element)
                                        });
                                    </script>
                                    {/if}
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" style="width: 90%;padding-top: 20px;">
                            <div class="layui-form-item">
                                <label class="layui-form-label">服务选择：</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="serverHost" value="localhost" title="本服务器" checked="">
                                    <input type="radio" name="serverHost" value="sina" title="新浪">
                                    <input type="radio" name="serverHost" value="bilibili" title="哔哩哔哩">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" style="width: 90%;padding-top: 20px;">
                            <div class="layui-form-item">
                                <label class="layui-form-label">允许下载：</label>
                                <div class="layui-input-block">
                                    {if condition="$bookInfo['allow_download'] eq 1"}
                                    <input type="checkbox" checked name="download" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF"> {else /}
                                    <input type="checkbox" name="download" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF"> {/if}
                                    <div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>OFF</em><i></i>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">允许评论：</label>
                                <div class="layui-input-block">
                                    {if condition="$bookInfo['allow_comment'] eq 1"}
                                    <input type="checkbox" checked name="comment" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF"> {else /}
                                    <input type="checkbox" name="comment" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF"> {/if}
                                    <div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>OFF</em><i></i>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">漫画封面： </label>
                        <div class="layui-input-block">
                            <div class="upload" data-type="png,jpg,jpeg,gif" action='/{$useradmin}/bookCover?saveType=1&time={$time}&encryption_bookId={$hashHmac_bookId}&bookId={$bookId}&pictureCloudAcceleration=' data-num='1' id='img-list'>
                            </div>
                        </div>

                    </div>

                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" style="width: 90%;padding-top: 20px;">
                            <div class="layui-form-item">
                                <label class="layui-form-label">分类选择：</label>
                                <div class="layui-input-block">
                                    <div id="categories" class="xm-select-demo"></div>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" style="width: 90%;padding-top: 20px;">
                            <div class="layui-form-item">
                                <label class="layui-form-label">标签选择:</label>
                                <div class="layui-input-block">
                                    <div id="tags" class="xm-select-demo"></div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="padding-left: 10px;">
                <div class="layui-input-block">
                    {if condition="$bookInfo['edit_sever_comics_info'] eq 1"}
                    <button class="layui-btn layui-btn-normal button-save-changes" lay-submit lay-filter="formDemo">保存更改数据</button> {/if}
                    <button type="reset" class="layui-btn layui-btn-primary button-refresh-page">刷新页面</button>
                </div>
            </div>
        </div>
    </div>
    <script>
        classified_catalogue = '{$classified_catalogue}';
        var c = document.createElement('div');
        c.innerHTML = classified_catalogue;
        classified_catalogue = c.innerText || c.textContent;
        c = null;

        var categories = xmSelect.render({ //渲染分类列表
            el: '#categories',
            filterable: true,
            data: JSON.parse(classified_catalogue)
        })
        classified_catalogue = '{$TagList}';

        var c = document.createElement('div');
        c.innerHTML = classified_catalogue;
        classified_catalogue = c.innerText || c.textContent;
        c = null;
        var tags = xmSelect.render({ //渲染分类列表
            el: '#tags',
            autoRow: true,
            toolbar: {
                show: true
            },
            filterable: true,
            remoteSearch: true,
            data: JSON.parse(classified_catalogue),
            remoteMethod: function(val, cb, show) {
                //这里如果val为空, 则不触发搜索
                if (!val) {
                    return cb(JSON.parse(classified_catalogue));
                }
                //这里引入了一个第三方插件axios, 相当于$.ajax
                $.ajax({
                    type: "post",
                    url: 'SelectController/SelectTags',
                    data: {
                        keyword: val,
                        toKen: me_token, //用户token
                        bookId: bookId,
                        time: time,
                        verificationBookId: verificationBookId,
                    },
                    dataType: "json",
                    success: function(response) {
                        if (response.code == 200) {
                            var res = response.data;
                            cb(res)
                        } else {
                            cb([{
                                "name": "创建-" + val,
                                "value": val,
                            }])
                        }
                    }
                });
            },
        })
    </script>
    <script src="/public/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        function ModifyUserInformation($user_id, $hash_hmac_str) { //用户修改信息 继承 转让
            var index = layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: false,
                skin: 'layer-test',
                content: '<div><img width="150" src="https://i0.hdslb.com/bfs/album/7f85abf4f2c87b70589e4b5a0b1d8fb340c0f2d4.gif"> <h1 style="text-align:center;font-size:30px;color:rgb(255,255,255);">拼命加载中</h1></div>'
            });

            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/Update",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },

                dataType: "json",
                success: function(response) {
                    layer.close(index);
                    if (response.code == 200) {
                        layer.open({
                            type: 0,
                            skin: 'layui-layer-demo', //样式类名
                            title: "操作成功",
                            closeBtn: 0, //不显示关闭按钮
                            anim: 2,
                            maxWidth: '50%',
                            maxHeight: '50%',
                            shadeClose: false, //开启遮罩关闭
                            content: '<div style="max-width:100%">' +
                                '<li style="text-align:center;" class="layer-area">' +
                                '<div style="text-align:center;">' +
                                '<img  draggable="false" style="max-Width:70%;max-height:60%;" src="https://i0.hdslb.com/bfs/album/481b5ceef0d56aa329652b269f5a02f447503e7b.png">' +
                                '<div style="text-align:center;">' +
                                '<font>操作成功</font>' +
                                '</div>' +
                                '</div>' +
                                '</li>' +
                                '</div>',
                            btn: ['确认', ] //可以无限个按钮
                                ,
                            btn1: function(index, layero) {
                                if ($user_id ==
                                    "{$user_info['_id']}") {
                                    window.location.reload();
                                } else {
                                    layer.close(index);
                                }
                            }
                        });
                    } else {
                        switch (response.code) {
                            case 1030:
                                var text = '权限不足,请刷新网页再试';
                                break;
                            case 1031:
                                var text = '您尚未做任何修改';
                                break;

                            default:
                                var text = '被玩坏了！请稍后或刷新网页再试,其他信息：' + response.detail;

                                break;
                        }
                        layer.open({
                            type: 0,
                            skin: 'layui-layer-demo', //样式类名
                            title: "发生意外错误",
                            closeBtn: 0, //不显示关闭按钮
                            anim: 2,
                            maxWidth: '50%',
                            maxHeight: '50%',
                            area: ['25%', '60%'],
                            shadeClose: false, //开启遮罩关闭
                            content: '<div style="max-width:100%">' +
                                '<li style="text-align:center;" class="layer-area">' +
                                '<div style="text-align:center;">' +
                                '<img  draggable="false" style="max-Width:70%;max-height:60%;" src="https://i0.hdslb.com/bfs/album/89f61ba7b2456dfd5af4bd92b485553274f73ad4.png">' +
                                '<div style="text-align:center;">' +
                                '<font>' + text + '</font>' +
                                '</div>' +
                                '</div>' +
                                '</li>' +
                                '</div>',
                            btn: ['确认', ] //可以无限个按钮
                                ,
                            btn1: function(index, layero) {
                                if ($user_id ==
                                    "{$user_info['_id']}") {
                                    window.location.reload();
                                } else {
                                    layer.close(index); //再执行关闭 
                                }

                            }
                        });
                    }
                }
            });
        }

        function InviteToJoin($user_id, $hash_hmac_str) { //邀请加入用户
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/InviteToJoin",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function RefuseToJoin($user_id, $hash_hmac_str) { //协作者邀请用户进入 创作者拒绝
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/RefuseToJoin",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function AllowToJoin($user_id, $hash_hmac_str) { //协作者邀请用户进入 创作者同意
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/AllowToJoin",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function Delete($user_id, $hash_hmac_str) { //删除用户 申请删除 
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/Delete",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function AgreeToDeleteUser($user_id, $hash_hmac_str) { //协作者申请删除用户 创作者同意
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/AgreeToDeleteUser",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function RefuseToDeleteUser($user_id, $hash_hmac_str) { //协作者申请删除用户 创作者同意
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/RefuseToDeleteUser",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function RecoveryUser($user_id, $hash_hmac_str) { //协作者申请删除用户 创作者拒绝
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/RecoveryUser",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function InheritedUsersAreAllowedToJoin($user_id, $hash_hmac_str) { //允许继承
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/InheritedUsersAreAllowedToJoin",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function RefuseToInherit($user_id, $hash_hmac_str) { //拒绝继承
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/RefuseToInherit",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }

        function addList() {
            var element = $([
                '<tr>',
                '<td>' + index + '</td>',
                '<td class="gender"></td>',
                '<td class="hobby"></td>',
                '<td class="state">待提交</td>',
                '<td class="handler">',
                '<button type="button" class="layui-btn layui-btn-normal get">取值</button>',
                '<button type="button" class="layui-btn layui-btn-danger del">删除</button>',
                '</td>',
                '</tr>',
            ].join(''))

            var hobby = element.find('.hobby')[0];
            var hobbySelect = xmSelect.render({
                el: hobby,
                filterable: true,
                radio: true,
                remoteSearch: true,
                model: {
                    label: {
                        type: 'text'
                    }
                },
                remoteMethod: function(val, cb, show) {
                    $.ajax({
                        type: "get",
                        url: 'https://www.fastmock.site/mock/98228b1f16b7e5112d6c0c87921eabc1/xmSelect/search',
                        data: {
                            keyword: val,
                        },
                        dataType: "json",
                        success: function(response) {
                            var res = response.data;
                            cb(res)
                        }
                    });
                },
                data: []
            })

            var gender = element.find('.gender')[0];
            xmSelect.render({
                el: gender,
                radio: true,
                clickClose: true,
                model: {
                    label: {
                        type: 'text'
                    }
                },
                data: function() {
                    if ('{$bookInfo["me_role"]}' == "author") {
                        return [{
                            name: '创建者',
                            value: 1
                        }, {
                            name: '协作者',
                            value: 2
                        }]
                    } else if ('{$bookInfo["me_role"]}' == "chinese_team") {
                        return [{
                            name: '协作者',
                            value: 1
                        }]
                    } else {
                        alert('发生意外错误数据返回错误');
                        return [{
                            name: '发生意外错误',
                            value: null
                        }]
                    }


                },
                on: function(data) {
                    var changeItem = data.change[0];
                    if (data.isAdd && changeItem.value == 3) {
                        this.update({
                            disabled: true
                        })
                    } else {
                        this.update({
                            disabled: false
                        })
                    }
                }.bind(hobbySelect),
            })

            element.find('.get').on('click', function() {
                alert('valueStr: ' + this.getValue('valueStr'));
            }.bind(hobbySelect))

            element.find('.del').on('click', function() {
                $(this).parents('tr').remove();
            })

            index++;

            $('#add-author-chinese_team tbody').append(element)
        }

        layui.use(['form', 'element'], function() {});
        $(function() {
            initialdata["20.jpg"] = {
                "filenameHome": "{$bookInfo['original_name']}",
                "filename": "{$bookInfo['original_name']}",
                "fileUrl": "{$bookInfo['file_server']}{$bookInfo['path']}",
            }
            $("#img-list").upload(

                function(_this, data) {
                    alert(data)
                }
            )
            $('button.button-save-changes').click(function(e) { //提交数据
                var index = layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    shadeClose: false,
                    skin: 'layer-test',
                    content: '<div><img width="150" src="https://i0.hdslb.com/bfs/album/7f85abf4f2c87b70589e4b5a0b1d8fb340c0f2d4.gif"> <h1 style="text-align:center;font-size:30px;color:rgb(255,255,255);">拼命加载中</h1></div>'
                });

                $.ajax({
                    type: "post",
                    url: "Comics/SaveInformation",
                    data: {
                        "categories": categories.getValue(), //分类
                        "tags": tags.getValue(), //标签
                        "toKen": me_token, //用户token
                        "comment": $("input[name='comment']").prop('checked'), //是否允许下载
                        "download": $("input[name='download']").prop('checked'), //是否允许评论
                        "title": $("input[name='title']").val(), //是否允许评论
                        "description": $("textarea[name='description']").val(), //是否允许评论
                        "bookId": bookId,
                        "time": time,
                        "verificationBookId": verificationBookId,
                    },
                    dataType: "json",
                    success: function(response) {
                        layer.close(index);
                        if (response.code == 200) {
                            layer.open({
                                type: 0,
                                skin: 'layui-layer-demo', //样式类名
                                title: "成功",
                                closeBtn: 0, //不显示关闭按钮
                                anim: 2,
                                maxWidth: '50%',
                                maxHeight: '50%',
                                area: ['25%', '60%'],
                                shadeClose: false, //开启遮罩关闭
                                content: '<div style="max-width:100%">' +
                                    '<li style="text-align:center;" class="layer-area">' +
                                    '<div style="text-align:center;">' +
                                    '<img  draggable="false" style="max-Width:70%;max-height:60%;" src="https://i0.hdslb.com/bfs/album/481b5ceef0d56aa329652b269f5a02f447503e7b.png">' +
                                    '<div style="text-align:center;">' +
                                    '<font>更新记录成功</font>' +
                                    '</div>' +
                                    '</div>' +
                                    '</li>' +
                                    '</div>',
                                btn: ['确认', ] //可以无限个按钮
                                    ,
                                btn1: function(index, layero) {
                                    layer.close(index); //再执行关闭 
                                }
                            });
                        } else {
                            switch (response.code) {
                                case 1030:
                                    var text = '权限不足,请刷新网页再试';
                                    break;
                                case 1031:
                                    var text = '您尚未做任何修改';
                                    break;

                                default:
                                    var text = '被玩坏了！请稍后或刷新网页再试,其他信息：' + response.detail;

                                    break;
                            }
                            layer.open({
                                type: 0,
                                skin: 'layui-layer-demo', //样式类名
                                title: "发生意外错误",
                                closeBtn: 0, //不显示关闭按钮
                                anim: 2,
                                maxWidth: '50%',
                                maxHeight: '50%',
                                area: ['25%', '60%'],
                                shadeClose: false, //开启遮罩关闭
                                content: '<div style="max-width:100%">' +
                                    '<li style="text-align:center;" class="layer-area">' +
                                    '<div style="text-align:center;">' +
                                    '<img  draggable="false" style="max-Width:70%;max-height:60%;" src="https://i0.hdslb.com/bfs/album/89f61ba7b2456dfd5af4bd92b485553274f73ad4.png">' +
                                    '<div style="text-align:center;">' +
                                    '<font>' + text + '</font>' +
                                    '</div>' +
                                    '</div>' +
                                    '</li>' +
                                    '</div>',
                                btn: ['确认', ] //可以无限个按钮
                                    ,
                                btn1: function(index, layero) {
                                    window.location.reload();
                                }
                            });
                        }
                    }
                });
            });

        })

        function DeleteStatusExceptionUser($user_id, $hash_hmac_str) { //协作者邀请用户进入 创作者同意
            var initListType = listTypeData[$user_id].getValue("value");
            var initListUser_id = listIdOrUserNameData[$user_id].getValue("value");
            $.ajax({
                type: "post",
                url: "AuthorAndChineseTeam/DeleteStatusExceptionUser",
                data: {
                    "initListType": initListType, //初始渲染时候的数据
                    "initListUser_id": $hash_hmac_str, //要操作的用户信息
                    "newListUser_id": initListUser_id, //如果变更了用户id这一条记录就喝上面的不一致
                    "toKen": me_token, //用户token
                    "bookId": bookId,
                    "time": time,
                    "verificationBookId": verificationBookId,
                },
                dataType: "json",
                success: function(response) {
                    if (response.code == 200) {

                    } else {

                    }
                }
            });
        }
    </script>

</body>

</html>